﻿
//关闭当前页 返回父页面
function closePage(isReload) {
    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
    parent.layer.close(index); //再执行关闭
    if (isReload) {
        parent.search();
    }
}

//showType 1图片 2文件
function showFileItem(fileJson, obj, showType) {
    var fileListHtml = '';
    $.each(fileJson, function (i, item) {
        var divHtml = '';
        if (showType == 1) {
            divHtml = '<div>';
            divHtml += '<img class="fileItem" src="' + item.AnnexPath + '" data-annexpath="' + item.AnnexPath + '" data-annexname="' + item.AnnexName
                + '" data-annexsize="' + item.AnnexSize + '" data-recordtype="' + item.RecordType
                + '" alt="' + item.AnnexName + '" onclick="viewImage(this)" />';
            //divHtml += '<a class="file-close" onclick="closeListItem(this)">X</a>';
            divHtml += '</div>';
        } else {
            divHtml = '<div>';
            divHtml += '<a class="fileItem" target="_blank" href="' + item.AnnexPath + '" data-annexpath="' + item.AnnexPath + '" data-annexname="' + item.AnnexName
                + '" data-annexsize="' + item.AnnexSize + '" data-recordtype="' + item.RecordType + '">' + item.AnnexName + '</a>';
            //divHtml += '<a class="file-close" onclick="closeListItem(this)">X</a>';
            divHtml += '</div>';
        }
        fileListHtml += divHtml;
    });
    $(obj).html(fileListHtml);
}

layui.use(['form', 'layer'], function () {
    var form = layui.form,
        layer = layui.layer;

    $(function () {
        if (app.getRequest('GUID')) {
            initData();
        }
    });

    //初始化表单
    function initData() {
        var fieldData = {
            GUID: app.getRequest('GUID'),
            PostType: "get",
            ActionType: "UserInfo"
        };
        app.loadData("UserInfoManage.ashx", fieldData, function (data) {
            var sex = data.Sex == 1 ? "男" : "女";
            $('#lblSex').text(sex);
            var isLock = data.IsLock == 1 ? "失效" : "正常";
            $('#lblIsLock').text(isLock);
            var userTypeName = "";
            var userType = data.UserType;
            if (userType == 2) {
                userTypeName = "系统管理员";
            } else if (userType == 3) {
                userTypeName = "普通账号";
            } else if (userType == 4) {
                userTypeName = "测试账号";
            }
            $('#lblUserType').text(userTypeName);

            if (data.PortraitUrl) {
                $("#jpgfile").attr('src', data.PortraitUrl + '?t=' + Math.random());
            }

            form.render();
        }, function (err) {
            layer.msg('请求失败');
        });
    }
});
